<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<sfa:mainTitle></sfa:mainTitle>
		<%@ include file="../../common/meta.jsp"%>


		<style type="text/css">
* {
	margin: 0;
	padding: 0;
}

.tc_box {
	width: 400px;
	height: 200px;
	border: 2px solid red;
	position: absolute;
	z-index: 2000;
	background: #FFC;
	display: none;
}

.sp_box {
	width: 100%;
	position: absolute;
	z-index: 1000;
	background: #000;
	top: 0;
	left: 0;
	display: none;
}
.title{ 
	width:160px; 
	white-space:nowrap; 
   word-break:keep-all; 
   overflow:hidden; 
   text-overflow:ellipsis; 
}
.main .formdiv {
	width: 400px;
}
</style>

<script type="text/javascript">
$(function() {
	$("#fullScreen").click(function() {
		fullScreen.FullScreen("mytable");
	});
})

jQuery.validator.addMethod("loginname", function(value, element) {
	var tel = /^[a-zA-Z][a-zA-Z0-9_]{4,16}$/;
	return this.optional(element) || (tel.test(value));
}, "");

jQuery.validator.addMethod("phonenumber", function(value, element) {
	var tel = /^(13[0-9]|15[0|3|6|7|8|9]|18[3|6|7|8|9])\d{8}$/;
	return this.optional(element) || (tel.test(value));
}, "");
$(function() {

	$("#clear").click(function() {
		$(".inputbox").val("");
	});
	var addForm = $("#addCustomerForm").validate( {

		rules : {
			customerName : {
				required : true
			},
			customerAddr : {
				required:true
				
			},
			customerPhone : {
				required : true
			},
			contract : {
				required : true
			},
			 
			mobile : {
				required :true,
				phonenumber : true
			}

		},
		messages : {
			customerName : {
				required : "必填"
			},
			customerAddr : {
				
					required : "必填"
			},
			customerPhone : {
				required : "必填"
			},
			contract : {
				required : "必填"
			}, 
			mobile : {
				required : "必填"
			},mobile : {
				phonenumber : "手机号码输入不正确"
			},
			focusInvalid : false,
			onkeyup : false
		//获得焦点时不验证
		}
	});

	$("#submit").click(function() {
		if (addForm.form()) {	
			$("#addCustomerForm").ajaxSubmit(function(result) {
				var json = eval(result);
				var msg = json.msg;
				if (json.result) {
					if (json.flag == true) {
						art.dialog( {
							icon : 'success',
							lock : true,
							resize : false,
							title : "添加成功",
							content : msg,
							ok:function(){
								location.href="${path}/customer/manage/index/getcustomers";
							}
						});
						
					} else {
						art.dialog( {
							icon : 'error',
							lock : true,
							resize : false,
							title : "添加失败",
							content : msg
						});
					}
				} else {

					alert(msg);
				}

			});

		}
	});

	//删除
	$(".deleteCustomer").click(function() {
		var saleHideCustomerId = $(this).attr("saleHideCustomerId");
		//alert(saleHideCustomerId);
			var url = "${path}/customer/manage/index/delete/"
					+ saleHideCustomerId;
			art.dialog( {
				lock : true,
				content : '确定要删除吗?',
				ok : function() {
					art.dialog( {
						id : "loading",
						lock : true,
						drag : false,
						resize : false,
						title : "正在删除...",
						time : 5
					});
					$.post(url, null, function(result) {
						var json = eval(result);
						art.dialog( {
							id : 'loading'
						}).close();//关闭等待框
							if (json.result == true) {
								art.dialog( {
									icon : "succeed",
									content : "删除成功!",
									lock : true,
									ok : function() {
										l
									}
								});
							} else {
								art.dialog( {
									icon : "error",
									content : "删除失败!",
									lock : true,
									ok : true
								});
							}

						});

					return true;
				},
				cancelVal : '关闭',
				cancel : true
			//为true等价于function(){}
					});

		});

});
</script>
	</head>



	<body id="master">

		<sfa:mainHeader></sfa:mainHeader>

		<!--右边-->
		<div class="webpart3 contentarea">
			<div class="webpart-head">
				<div class="webpart-head-item">
					准客户维护
					<font color="red"><c:out value="${add}"></c:out> </font>
					<div class="tools-btn">

						 &nbsp;&nbsp;<a href="javascript:" onclick="javascript:history.go(-1);"><span>
                                <img src="${path}/statics/images/Redo.gif" style="margin-right: 4px; margin-bottom: -3px;" />返回</span></a>
					</div>
				</div>
			</div>
			<div class="webpart-main">
				<div class="webpart-main-item" style="padding-top: 12px;">
					<div class="search">
						<!----------- 查询信息 ------------------>
						<form id="addCustomerForm"
							action="${path}/customer/manage/index/add" method="post">
							<table cellpadding="0" cellspacing="0" >
							<tr><th colspan="6"><font color="red">(后面带*为必填项)</font></th></tr>
                                <tr >
                                    <th style="vertical-align: top;">
                                        创建人：
                                    </th>
                                    <td>
                                        ${user.userName}(${user.loginName})
                                    </td>
                            </tr>
                            <tr>  
                                    <th style="vertical-align: top;">
                                       客户姓名:
                                    </th>
                                    <td>
                                        <input type="text" class="input-txt" id="customerName"  
										name="customerName"  />
										<font color='red'>*</font>
									 
                                    </td>
                                    
                                </tr>
                                 <tr>   
                                    <th>
                                     客户地址:
                                     </th>
                                     <td>
                                        <input type="text" class="input-txt" id="customerAddr"  
										name="customerAddr"  />
										<font color='red'>*</font>
                                    </td>
                                    
                                </tr>
                                <tr>   
                                    <th>
                                     邮编:
                                     </th>
                                     <td>
                                        <input type="text" class="input-txt" id="customerCode"  
										name="customerCode"  />
                                    </td>
                                    
                                </tr>
                                <tr>   
                                    <th>
                                     客户电话:
                                     </th>
                                     <td>
                                        <input type="text" class="input-txt" id="customerPhone"  
										name="customerPhone"  />
										<font color='red'>*</font>
                                    </td>
                                    
                                </tr>
                                
                                <tr>
                                	<th style="vertical-align: top;">
                                       客户类型:
                                	</th>
                                	<td>
                                		<sfa:dic showType="select" kindNo="CUSTOMERTYPE"
										 attr="class='input-txt' style='width:130px'"   
										name="customerType" id="customerType">
									</sfa:dic>
                                	</td>
                                	 
                                	 
                                </tr>
                                <tr>
                                
                                 <th style="vertical-align: top;">
                                        联系人:
                                    </th>
                                    <td colspan="2">
                                        <input type="text" class="input-txt" id="contract"  
										name="contract" />
										   <font color="red" class="contract"> </font>
                                    </td>
                                </tr>
                                <tr>
                                
                                 <th style="vertical-align: top;">
                                       职位:
                                    </th>
                                    <td colspan="2">
                                        <input type="text" class="input-txt" id="position"  
										name="position" />
                                    </td>
                                </tr>
                                
                                <tr>
                                
                                 <th style="vertical-align: top;">
                                        手机号码:
                                    </th>
                                    <td colspan="2">
                                        <input type="text" class="input-txt" id="mobile"  
										name="mobile" />
										   <font color="red" class="mobile"> </font>
                                    </td>
                                </tr>
                                <tr>
                                
                                 <th style="vertical-align: top;">
                       QQ:
                                    </th>
                                    <td colspan="2">
                                        <input type="text" class="input-txt" id="QQ"  
										name="QQ" />
                                    </td>
                                </tr>
                                <tr>
                                
                                 <th style="vertical-align: top;">
                       email:
                                    </th>
                                    <td colspan="2">
                                        <input type="text" class="input-txt" id="email"  
										name="email" />
                                    </td>
                                </tr>
                                
                                
                                
                                
                                <tr>
                                	<td align="center" colspan="9">
                                	 <input name="submit" type="button" id="submit" tabindex="5"
										class="linkbtn2" value="提交">
									<input name="clear" type="reset" id="clear" tabindex="5"
										class="linkbtn2" value="清空">
                                	</td>
                                </tr>
                                 
                            </table>
						</form>
					</div>
					 
				</div>
			</div>
			<div class="webpart-foot">
				<div class="webpart-foot-item">
				</div>
			</div>
		</div>
		<sfa:mainFooter></sfa:mainFooter>
	</body>
</html>


